<template>
  <div class="pk-cell">
    <div class="pk-cell-item" v-for="(item, index) in cellconfig" :key="index">
      <div class="pk-cell-content">
        <div class="pk-cell-icon" v-if="item.icon"></div>
        <div class="pk-cell-info">
          <div class="pk-cell-title" :class="{'pk-cell-bold': bold}" v-if="item.label">{{ item.label }}</div>
          <div class="pk-cell-subtitle" v-if="item.subtitle">{{ item.subtitle }}</div>
        </div>
        <div class="pk-cell-moreoptions">
          <slot :name="item.slotName" v-if="item.slotName"></slot>
          <div class="pk-cell-celldata" v-if="item.prop">{{ data[item.prop] }}</div>
          <div class="pk-cell-more" v-if="isLink" @click="handlerItem(data, item)"></div>
        </div> 
      </div>
      <div class="pk-cell-order" v-if="order && index != cellconfig.length -1 ">
        <pk-line></pk-line>
      </div>
    </div>
  </div>
</template>

<script setup>
import { defineProps } from 'vue';
defineProps({
  cellconfig: {
    type: Array,
    default: () => []
  },
  data:{
    type: Object,
    default: () => {}
  },
  isLink: {
    type: Boolean,
    default: false
  },
  order:{
    type: Boolean,
    default: true
  },
  bold:{
    type: Boolean,
    default: true
  }
})

const handlerItem = (data, item) => {
  item.on && item.on(data)
}

</script>

<style lang="scss" scoped>
.pk-cell{
  padding: 0 24rpx;
  background: #fff;
  border-radius: $uni-border-radius-base;
  box-shadow: 0px 8rpx 32px 0px rgba(0,0,0,0.06);
  &-icon{
    width: 40rpx;
    height: 40rpx;
    background: #000;
    border-radius: 40rpx;
    margin-right: 16rpx;
  }
  &-content {
    padding: 16rpx 0;
    display: flex;
    flex-direction: row;
    align-items: center;
  }
  &-info{
    flex: 1;
  }
  &-title{
    font-size: $uni-font-size-base;
    // font-weight: bold;
    height: 64rpx;
    line-height: 64rpx;
  }
  &-bold{
    font-weight: bold;
  }
  &-subtitle{
    font-size: $uni-font-size-sm;
    color: $uni-text-color-grey;
    height: 44rpx;
    line-height: 44rpx;
  }
  &-celldata{
    color: $uni-text-color-grey;
  }
  &-moreoptions{
    display: flex;
    flex-direction: row;
    font-size: $uni-font-size-base;
    align-items: center;
  }
  &-more{
    display: flex;
    align-items: center;
    justify-content: center;
    width: 64rpx;
    background: url('@/static/pkui/moreicon.png') center center no-repeat;
    background-size: 32rpx auto;
    height: 64rpx;
  }
}
</style>